def word_to_number(word):
    numbers = {
        'zero': '0', 'one': '1', 'two': '2', 'three': '3',
        'four': '4', 'five': '5', 'six': '6', 'seven': '7',
        'eight': '8', 'nine': '9'
    }
    return numbers.get(word)

def is_prime(number):
    if number < 2:
        return False
    for i in range(2, int(number**0.5) + 1):
        if number % i == 0:
            return False
    return True

def find_closest_prime(start_number):
    if is_prime(start_number):
        return start_number
    
    lower = start_number - 1
    upper = start_number + 1
    
    while True:
        if is_prime(lower):
            return lower
        elif is_prime(upper):
            return upper
        else:
            lower -= 1
            upper += 1

input_text = input("Введите три слова на английском языке, разделенных пробелом: ")
words = input_text.split()

if len(words) != 3:
    print("Wrong input")
else:
    number = int(word_to_number(words[0]) + word_to_number(words[1]) + word_to_number(words[2]))
    if 2 <= number < 1000:
        closest_prime = find_closest_prime(number)
        print(closest_prime)
    else:
        print("Wrong input")




